﻿using SearchScreen.SDK;
using System;
using System.Collections.Generic;
using System.ComponentModel.Composition;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace SearchScreen.ExtendedComponentSample
{
    /// <summary>
    /// Interaction logic for DateTimeUC.xaml
    /// </summary>
    [Export(typeof(IFrameworkElementFactoryProvider))]
    [ExportMetadata("Field", "DATE_START")]
    public partial class DateTimeUC : UserControl, IFrameworkElementFactoryProvider
    {
        public DateTimeUC()
        {
            InitializeComponent();
        }

        public DateTime? SelectedDate
        {
            get { return (DateTime?)GetValue(SelectedDateProperty); }
            set { SetValue(SelectedDateProperty, value); }
        }

        // Using a DependencyProperty as the backing store for SelectedDate.  This enables animation, styling, binding, etc...
        public static readonly DependencyProperty SelectedDateProperty =
            DependencyProperty.Register("SelectedDate", typeof(DateTime?), typeof(DateTimeUC), new PropertyMetadata());
        

        public FrameworkElementFactory GetFactory(Binding targetPropertyBinding)
        {
            var factory = new FrameworkElementFactory(GetType());
            factory.SetBinding(
                DateTimeUC.SelectedDateProperty,
                targetPropertyBinding);

            return factory;
        }
    }
}
